package com.maybach.core.dubbo.consumer.adapter;

import com.audi.dubbo.api.admin.AdminService;
import com.audi.dubbo.api.admin.models.AdminModel;
import com.maybach.core.dubbo.consumer.annotation.Monitor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by weishuai on 16/1/14.
 */

@Component
@Monitor(serviceName = "adminService",desc = "小二后台服务")
public class AdminServiceDubooAdapter {
    private  Logger log = LoggerFactory.getLogger(this.getClass());

    @Autowired
    AdminService adminService;

    public AdminModel getAdminModelByLoginName(String loginName){
        AdminModel adminModel=new AdminModel();
        try {
            adminModel=adminService.getAdminModel(loginName);
        } catch (Exception e) {
            log.error("error in getAdminModelByLoginName,loginName:"+loginName,e);
        }
        return adminModel;

    }

    public  AdminModel getAdminModelByAdminId(Long adminId){
        try {
            return adminService.getAdminModel(adminId);
        } catch (Exception e) {
            log.error("error in getAdminModelByAdminId,adminId:"+adminId, e);
            return new AdminModel();
        }
    }

    public List<AdminModel> getAdminModelByRoleCode(String roleCode){
        try {
            return adminService.getAdminModelByRoleCode(roleCode);
        } catch (Exception e) {
            log.error("error in getAdminModelByRoleCode,roleCode:"+roleCode, e);
            return new ArrayList<AdminModel>();
        }
    }
}
